package com.rest.demo.concurrent;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;

/**
 * @author Administrator
 * @decription
 * @Date 2018-02-01 10:49
 */
public class AtomicIntDemo {

    private final static AtomicInteger TEST_INTEGER = new AtomicInteger(1);

    public static void main(String[] args) {
        IntStream.range(0,10).forEach(i -> new Thread(() -> {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            int now = TEST_INTEGER.incrementAndGet();
            System.out.println(Thread.currentThread().getName() + " get value : " + now);
        }).start());
    }
}
